home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_08 / 9n08014b < prev    next >
Text File  |  1991-07-08  |  579b  |  24 lines

  1. /* frexp function */
  2. #include "xmath.h"
  3.  
  4. double (frexp)(double x, int *pexp)
  5.         {       /* compute frexp(x, &i) */
  6.         short binexp;
  7.  
  8.         switch (_Dunscale(&binexp, &x))
  9.                 {       /* test for special codes */
  10.         case NAN:
  11.         case INF:
  12.                 errno = EDOM;
  13.                 *pexp = 0;
  14.                 return (x);
  15.         case 0:
  16.                 *pexp = 0;
  17.                 return (0.0);
  18.         default:        /* finite */
  19.                 *pexp = binexp;
  20.                 return (x);
  21.                 }
  22.         }
  23.  
  24.